// 波形数据有MATLAB生成，为了确保波形可以连续，对于周期为N的波，需要收集0~N-1对应的采样点
// 自带的pi精度不够，需要自己设置，比如
// PI=3.141592535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480
// 开个玩笑，选取到3.1415925359就行了
const uint8_t sine_wave[400] = {
        127,143,159,174,188,202,214,225,235,242,
        248,252,254,254,252,248,242,235,225,214,
        202,188,174,159,143,127,111,95,80,66,
        52,40,29,19,12,6,2,0,0,2,
        6,12,19,29,40,52,66,80,95,111,
        127,143,159,174,188,202,214,225,235,242,
        248,252,254,254,252,248,242,235,225,214,
        202,188,174,159,143,127,111,95,80,66,
        52,40,29,19,12,6,2,0,0,2,
        6,12,19,29,40,52,66,80,95,111,
        127,143,159,174,188,202,214,225,235,242,
        248,252,254,254,252,248,242,235,225,214,
        202,188,174,159,143,127,111,95,80,66,
        52,40,29,19,12,6,2,0,0,2,
        6,12,19,29,40,52,66,80,95,111,
        127,143,159,174,188,202,214,225,235,242,
        248,252,254,254,252,248,242,235,225,214,
        202,188,174,159,143,127,111,95,80,66,
        52,40,29,19,12,6,2,0,0,2,
        6,12,19,29,40,52,66,80,95,111,
        127,143,159,174,188,202,214,225,235,242,
        248,252,254,254,252,248,242,235,225,214,
        202,188,174,159,143,127,111,95,80,66,
        52,40,29,19,12,6,2,0,0,2,
        6,12,19,29,40,52,66,80,95,111,
        127,143,159,174,188,202,214,225,235,242,
        248,252,254,254,252,248,242,235,225,214,
        202,188,174,159,143,127,111,95,80,66,
        52,40,29,19,12,6,2,0,0,2,
        6,12,19,29,40,52,66,80,95,111,
        127,143,159,174,188,202,214,225,235,242,
        248,252,254,254,252,248,242,235,225,214,
        202,188,174,159,143,127,111,95,80,66,
        52,40,29,19,12,6,2,0,0,2,
        6,12,19,29,40,52,66,80,95,111,
        127,143,159,174,188,202,214,225,235,242,
        248,252,254,254,252,248,242,235,225,214,
        202,188,174,159,143,127,111,95,80,66,
        52,40,29,19,12,6,2,0,0,2,
        6,12,19,29,40,52,66,80,95,111

};


const uint8_t square_wave[400] = {
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0,
        255,255,255,255,255,0,0,0,0,0




//        255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
//        255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
//        255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
//        255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
//        255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
//        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//        255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
//        255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
//        255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
//        255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
//        255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
//        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//        255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
//        255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
//        255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
//        255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
//        255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
//        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//        255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
//        255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
//        255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
//        255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
//        255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
//        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};



// 代码如下：
/*
% 定义参数
        N = 128; % 采样点数
        t = (0:N-1) / (N); % 时间向量，
% 为了确保波形数据可以连续，那么波形数据的周期为N，采样点需要为N-1，确保最后一个点不应该与第一个点对齐

% 生成波形
        PI = 3.14159265359;% 使用pi精度太低
        sineWave = round(127.5 * sin(2 * PI * t) + 127.5); % 正弦波

% triangleWave = round(255 * abs(2 * mod(t, 0.5) - 0.5)); % 三角波
% squareWave = round((sin(2 * pi * t) >= 0) * 255); % 方波
% sawtoothWave = round(255 * mod(t, 1)); % 锯齿波

% 将波形转换为C语言数组形式
        functionToCArray('sine_wave', sineWave);
% functionToCArray('triangleWave', triangleWave);
% functionToCArray('squareWave', squareWave);
% functionToCArray('sawtoothWave', sawtoothWave);

% 辅助函数，用于将向量转换成C语言数组形式并打印
        function functionToCArray(name, wave)
fprintf('const uint8_t %s[%d] = {\n', name, length(wave));
fprintf('%d', wave(1));
for i = 2:length(wave)
fprintf(', %d', wave(i));
end
        fprintf('\n};\n\n');
end
 */
